using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FiltronASP.Models;
using FiltronASP.Models.DAO.WIX;
using FiltronASP.Models.DAO.Extensions;
using FiltronASP.Models.DAO.Interfaces.WIX;
using FiltronASP.Models.DAO.Filtron;
using FiltronASP.Models.DAO.Interfaces.Filtron;
using FiltronASP.Helpers.Translations;
using FiltronASP.Helpers.CatalogueHelpers;
using System.IO;
using System.Net;
using System.Web.Script.Serialization;
using System.Text.RegularExpressions;

namespace FiltronASP.Helpers.MobileAjax
{
    public static class MobileAjaxHelper {
        
        // generowanie marek samochodów
        public static string getBrands(string market, int vehicleId, string languageName)
        {
            List<CustomDoubleVarObject> optionsList = new List<CustomDoubleVarObject>();
            optionsList.Add(new CustomDoubleVarObject(-1, translationHelper.getTranslation("_selectManufacturer", languageName)));
            switch (market) { 
                case "filtron":
                    IFiltronMakeDAO filtronMakesDAO = new FiltronMakeDAO();
                    IQueryable<FiltronMake> filtronMakes = filtronMakesDAO.FindByVehicle(vehicleId);

                    if (filtronMakes != null)
                    {
                        foreach (FiltronMake make in filtronMakes)
                        {
                            CustomDoubleVarObject currentMake = new CustomDoubleVarObject();
                            currentMake.Id = make.make_id;
                            currentMake.Name = make.make_name;
                            optionsList.Add(currentMake);
                        }
                    }   //if
                    break;

                case "wix":
                    IWixMakeDAO WixMakeDAO = new WixMakeDAO();
                    IQueryable<WixMake> wixMakesCollection = WixMakeDAO.FindByVehicle(vehicleId);
                    if (wixMakesCollection != null)
                    {
                        foreach (WixMake make in wixMakesCollection)
                        {
                            CustomDoubleVarObject currentMake = new CustomDoubleVarObject();
                            currentMake.Id = make.make_id;
                            currentMake.Name = make.make_name;
                            optionsList.Add(currentMake);
                        }
                    }
                    break;
                default:
                    optionsList.Clear();
                    optionsList.Add(new CustomDoubleVarObject(-2, "wrong parameters"));
                    break;
            }
            if (optionsList.Count == 1) {
                optionsList.Clear();
                optionsList.Add(new CustomDoubleVarObject(-3, "wrong parameters"));
            }
            return optionsList.ToJSON();
        }

        public static string getModels(string market, int brandId, string languageName) {
            List<CustomDoubleVarObject> optionsList = new List<CustomDoubleVarObject>();
            optionsList.Add(new CustomDoubleVarObject(-1, translationHelper.getTranslation("_selectModel", languageName)));
            switch (market)
            {
                case "filtron":
                    IFiltronModelDAO filtronModelDAO = new FiltronModelDAO();
                    IQueryable<FiltronModel> filtronModels = filtronModelDAO.FindByMake(brandId);

                    if (filtronModels != null)
                    {
                        foreach (FiltronModel model in filtronModels)
                        {
                            CustomDoubleVarObject currentModel = new CustomDoubleVarObject();
                            currentModel.Id = model.model_id;
                            currentModel.Name = model.model_name;
                            optionsList.Add(currentModel);
                        }
                    }   //if
                    break;

                case "wix":
                    IWixModelDAO wixModelDAO = new WixModelDAO();
                    IQueryable<WixModel> wixModels = wixModelDAO.FindByMake(brandId);
                    if (wixModels != null)
                    {
                        foreach (WixModel model in wixModels)
                        {
                            CustomDoubleVarObject currentModel = new CustomDoubleVarObject();
                            currentModel.Id = model.model_id;
                            currentModel.Name = model.model_name;
                            optionsList.Add(currentModel);
                        }
                    }
                    break;
                default:
                    optionsList.Clear();
                    optionsList.Add(new CustomDoubleVarObject(-1, "wrong parameters"));
                    break;
            }
            if (optionsList.Count == 1)
            {
                optionsList.Clear();
                optionsList.Add(new CustomDoubleVarObject(-1, "wrong parameters"));
            }
            return optionsList.ToJSON();
        }

        public static string getEngines(string market, int modelId, string languageName) {
            List<EngineObject> optionsList = new List<EngineObject>();
            switch (market) {
                case "filtron":
                    IFiltronEngineDAO filtronEngineDAO = new FiltronEngineDAO();
                    IQueryable<FiltronEngine> filtronEngines = filtronEngineDAO.FindByModel(modelId);
                    if (filtronEngines != null) {
                        foreach (var filtronEngine in filtronEngines) {
                            EngineObject currentEngine = new EngineObject();
                            currentEngine.Id = filtronEngine.engine_id;
                            currentEngine.Name = filtronEngine.engine_name;
                            currentEngine.CubicCapacity = filtronEngine.engine_cubic_capacity;
                            currentEngine.Code = filtronEngine.engine_code;
                            currentEngine.HorsePower = filtronEngine.engine_horse_power;
                            optionsList.Add(currentEngine);
                        }
                    }
                    break;
                case "wix":
                    IWixEngineDAO wixEngineDAO = new WixEngineDAO();
                    IQueryable<WixEngine> wixEngines = wixEngineDAO.FindByModel(modelId);
                    if (wixEngines != null) {
                        foreach (var wixEngine in wixEngines) {
                            EngineObject currentEngine = new EngineObject();
                            currentEngine.Id = wixEngine.engine_id;
                            currentEngine.Name = wixEngine.engine_name;
                            currentEngine.CubicCapacity = (wixEngine.engine_cubic_capacity == null) ? "---" : wixEngine.engine_cubic_capacity;
                            currentEngine.Code = (wixEngine.engine_code == null) ? "---" : wixEngine.engine_code;
                            currentEngine.HorsePower = (wixEngine.engine_horse_power == null) ? "---" : wixEngine.engine_horse_power;
                            optionsList.Add(currentEngine);
                        }
                    }
                    break;
                default:
                    optionsList.Clear();
                    optionsList.Add(new EngineObject(-2, "wrong parameters"));
                    break;
            }
            if (optionsList.Count == 0)
            {
                optionsList.Clear();
                optionsList.Add(new EngineObject(-3, "wrong parameters"));
            }
            return optionsList.ToJSON();
        }

        public static string getTypes(string market, int modelId, int engineId, string languageName) {
            List<CustomDoubleVarObject> optionsList = new List<CustomDoubleVarObject>();
            optionsList.Add(new CustomDoubleVarObject(-1, translationHelper.getTranslation("_selectType", languageName)));
            switch (market) {
                case "filtron":
                    IFiltronFilterEngineDAO filtronFilterEngineDAO = new FiltronFilterEngineDAO();
                    IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
                    IQueryable<FiltronFilterEngine> filtronFilterEngines = filtronFilterEngineDAO.FindByEngineAndModel(engineId, modelId);
                    List<int> uniqueFilterStyleIds = new List<int>();
                    if (filtronFilterEngines != null)
                    {
                        foreach (var filterEngine in filtronFilterEngines)
                        {
                            FiltronFilter currentFilter = filtronFilterDAO.FindByPK(filterEngine.filter_id);
                            if (!uniqueFilterStyleIds.Contains(Convert.ToInt32(currentFilter.filter_style_id))) {
                                uniqueFilterStyleIds.Add(Convert.ToInt32(currentFilter.filter_style_id));
                            }
                        }
                    }
                    if (uniqueFilterStyleIds.Contains(1))
                        optionsList.Add(new CustomDoubleVarObject(1, translationHelper.getTranslation("_oilFilter", languageName)));
                    if (uniqueFilterStyleIds.Contains(2))
                        optionsList.Add(new CustomDoubleVarObject(2, translationHelper.getTranslation("_airFilter", languageName)));
                    if (uniqueFilterStyleIds.Contains(3))
                        optionsList.Add(new CustomDoubleVarObject(3, translationHelper.getTranslation("_fuelFilter", languageName)));
                    if (uniqueFilterStyleIds.Contains(4))
                    {
                        optionsList.Add(new CustomDoubleVarObject(4, translationHelper.getTranslation("_cabinFilter", languageName)));
                        //optionsList.Add(new CustomDoubleVarObject(4, translationHelper.getTranslation("_cabinFilter", languageName) + " (" + translationHelper.getTranslation("_cabinCarbon", languageName) + ")"));
                    }
                        if (uniqueFilterStyleIds.Contains(5) || uniqueFilterStyleIds.Contains(6)
                            || uniqueFilterStyleIds.Contains(7) || uniqueFilterStyleIds.Contains(8)
                            || uniqueFilterStyleIds.Contains(9) || uniqueFilterStyleIds.Contains(10))
                        {
                            optionsList.Add(new CustomDoubleVarObject(0, translationHelper.getTranslation("_hlpOther", languageName)));
                        }
                    break;
                case "wix":
                    IWixFilterEngineDAO wixFilterEngineDAO = new WixFilterEngineDAO();
                    IWixFilterDAO wixFilterDAO = new WixFilterDAO();
                    IQueryable<WixFilterEngine> wixFilterEngines = wixFilterEngineDAO.FindByEngineAndModel(engineId, modelId);
                    List<int> uniqueFilterTypesIds = new List<int>();
                    if (wixFilterEngines != null)
                    {
                        foreach (var filterEngine in wixFilterEngines)
                        {
                            WixFilter currentFilter = wixFilterDAO.FindByPK(filterEngine.filter_id);
                            if (!uniqueFilterTypesIds.Contains(Convert.ToInt32(currentFilter.filter_type_id)))
                            {
                                uniqueFilterTypesIds.Add(Convert.ToInt32(currentFilter.filter_type_id));
                            }
                        }
                    }

                    if (uniqueFilterTypesIds.Contains(40))
                        optionsList.Add(new CustomDoubleVarObject(40, translationHelper.getTranslation("_oilFilter", languageName)));
                    if (uniqueFilterTypesIds.Contains(48))
                        optionsList.Add(new CustomDoubleVarObject(48, translationHelper.getTranslation("_airFilter", languageName)));
                    if (uniqueFilterTypesIds.Contains(47))
                        optionsList.Add(new CustomDoubleVarObject(47, translationHelper.getTranslation("_fuelFilter", languageName)));
                    if (uniqueFilterTypesIds.Contains(52))
                        optionsList.Add(new CustomDoubleVarObject(52, translationHelper.getTranslation("_cabinFilter", languageName)));
                    if (!uniqueFilterTypesIds.Contains(40) && !uniqueFilterTypesIds.Contains(48) && !uniqueFilterTypesIds.Contains(47) && !uniqueFilterTypesIds.Contains(52))
                        optionsList.Add(new CustomDoubleVarObject(0, translationHelper.getTranslation("_hlpOther", languageName)));    
                    
                    
                    break;
                 default:
                    optionsList.Clear();
                    optionsList.Add(new CustomDoubleVarObject(-2, "wrong parameters"));
                    break;
            }
            if (optionsList.Count == 1)
            {
                optionsList.Clear();
                optionsList.Add(new CustomDoubleVarObject(-3, "wrong parameters"));
            }
            return optionsList.ToJSON();
        }

        public static string getFilters(string market, int modelId, int engineId, int filterTypeId, string languageName) {
            List<CustomDoubleVarObject> optionsList = new List<CustomDoubleVarObject>();
            optionsList.Add(new CustomDoubleVarObject(-1, translationHelper.getTranslation("_selectFilter", languageName)));
            switch (market) {
                case "filtron":
                    IFiltronFilterEngineDAO filtronFilterEngineDAO = new FiltronFilterEngineDAO();
                    IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
                    IQueryable<FiltronFilterEngine> filtronFilterEngines = filtronFilterEngineDAO.FindByEngineAndModel(engineId, modelId);
                    List<int> uniqueFiltersIds = new List<int>();
                    if (filtronFilterEngines != null) { 
                        foreach (var filterEngine in filtronFilterEngines) {
                            if (!uniqueFiltersIds.Contains(filterEngine.filter_id)) {
                                uniqueFiltersIds.Add(filterEngine.filter_id);
                                FiltronFilter currentFilter = filtronFilterDAO.FindByPK(filterEngine.filter_id);
                                if (currentFilter.filter_style_id.Equals(filterTypeId)) {
                                    if (currentFilter.filter_wix_number_hd.Length > 0) {
                                        optionsList.Add(new CustomDoubleVarObject(currentFilter.filter_id, currentFilter.filter_wix_number_hd));
                                    }
                                    else {
                                        optionsList.Add(new CustomDoubleVarObject(currentFilter.filter_id, currentFilter.filter_wix_number));
                                    }
                                }
                            }
                        }
                    }
                    break;
                case "wix":
                    IWixFilterEngineDAO wixFilterEngineDAO = new WixFilterEngineDAO();
                    IWixFilterDAO wixFilterDAO = new WixFilterDAO();
                    IQueryable<WixFilterEngine> wixFilterEngines = wixFilterEngineDAO.FindByEngineAndModel(engineId, modelId);
                    List<int> uniqueWixFiltersIds = new List<int>();
                    if (wixFilterEngines != null) {
                        foreach (var filterEngine in wixFilterEngines) {
                            if (!uniqueWixFiltersIds.Contains(filterEngine.filter_id)) {
                                uniqueWixFiltersIds.Add(filterEngine.filter_id);
                                WixFilter currentFilter = wixFilterDAO.FindByPK(filterEngine.filter_id);
                                if (currentFilter.filter_type_id.Equals(filterTypeId)) {
                                    optionsList.Add(new CustomDoubleVarObject(currentFilter.filter_id, currentFilter.filter_number));
                                }
                            }
                        }
                    }
                    break;
                default:
                    optionsList.Clear();
                    optionsList.Add(new CustomDoubleVarObject(-1, "wrong parameters"));
                    break;
            }
            if (optionsList.Count == 1)
            {
                optionsList.Clear();
                optionsList.Add(new CustomDoubleVarObject(-1, "wrong parameters"));
            }
            return optionsList.ToJSON();
        }

        public static string getFilter(string market, int filterId, string languageName) {
            switch (market) { 
                case "filtron":
                    IFiltronFilterDAO filtronFilterDAO = new FiltronFilterDAO();
                    FiltronFilterObject filterObject = new FiltronFilterObject();
                    FiltronFilter currentFilter = filtronFilterDAO.FindByPK(filterId);

                    string imgPath = @"http://wixeurope.com/Content/images/filters/Filtron/" + FiltronHelper.GetFiltronFilterNumber(currentFilter, false) + ".jpg";
                    string imgUrl = String.Empty;
                    string imgUrlLarge = String.Empty;
                    var request = (HttpWebRequest)WebRequest.Create(imgPath);
                    request.Method = "HEAD";
                    try
                    {
                        var response = (HttpWebResponse)request.GetResponse();
                        imgUrl = imgPath;
                        imgUrlLarge = @"http://wixeurope.com/Content/images/filters/Filtron/large/" + FiltronHelper.GetFiltronFilterNumber(currentFilter, false) + ".jpg";
                    }
                    catch
                    {
                        IFiltronFilterMediaDAO filtronFilterMediaDAO = new FiltronFilterMediaDAO();
                        FiltronFilterMedia filterMedia = filtronFilterMediaDAO.FindByPK(currentFilter.filter_media_id);
                        string orgFilterMedia = String.Empty;
                        if (filterMedia != null)
                        {
                            orgFilterMedia = filterMedia.media_name;
                            string RepImageName = FiltronHelper.GetFiltronFilterImage(orgFilterMedia);
                            imgUrl = String.Format(@"http://wixeurope.com/Content/images/filters/Filtron/{0}.jpg", RepImageName);
                            imgUrlLarge = imgUrl;
                        }
                    }

                    if (currentFilter != null)
                    {
                        filterObject.Id = currentFilter.filter_id;
                        filterObject.Number = GetFiltronFilterWixNumber(currentFilter.filter_wix_number, currentFilter.filter_wix_number_hd);
                        filterObject.DimA = currentFilter.filter_dim_a;
                        filterObject.DimB = currentFilter.filter_dim_b;
                        filterObject.DimC = currentFilter.filter_dim_c;
                        filterObject.DimD = currentFilter.filter_dim_d;
                        filterObject.DimE = currentFilter.filter_dim_e;
                        filterObject.DimF = currentFilter.filter_dim_f;
                        filterObject.DimG = GetFilterDimG(currentFilter.filter_dim_g, currentFilter.filter_dim_g_text);
                        filterObject.DimH = currentFilter.filter_dim_h;
                        filterObject.ByPassValve = Convert.ToBoolean(currentFilter.filter_by_pass_valve);
                        filterObject.AntiDrainValve = Convert.ToBoolean(currentFilter.filter_anti_drain_valve);
                        filterObject.AntiSiphonValve = Convert.ToBoolean(currentFilter.filter_anti_siphon_valve);
                        filterObject.PrincipleApplications = currentFilter.filter_principle_applications;
                        filterObject.t_Filter = translationHelper.getTranslation("_filter", languageName);
                        filterObject.t_Sizes = translationHelper.getTranslation("_hlpSizes", languageName);
                        filterObject.t_ByPassValve = translationHelper.getTranslation("_hlpByPassValve", languageName);
                        filterObject.t_AntiDrainValve = translationHelper.getTranslation("_hlpAntiDrain", languageName);
                        filterObject.t_AntiSiphonValve = translationHelper.getTranslation("_hlpAntiSiphon", languageName);
                        filterObject.t_PrincipleApplications = translationHelper.getTranslation("_hlpApplication", languageName);
                        filterObject.t_Zoom = translationHelper.getTranslation("_hlpZoom", languageName);
                        filterObject.t_Yes = translationHelper.getTranslation("_hlpYes", languageName);
                        filterObject.t_No = translationHelper.getTranslation("_hlpNo", languageName);
                        filterObject.imageUrl = imgUrl;
                        filterObject.largeImageUrl = imgUrlLarge;
                    }
                    return filterObject.ToJSON();
                case "wix":
                    IWixFilterDAO wixFilterDAO = new WixFilterDAO();
                    WixFilterObject wixFilterObject = new WixFilterObject();
                    WixFilter wixCurrentFilter = wixFilterDAO.FindByPK(filterId);

                    string wiximgPath = @"http://wixeurope.com/Content/images/filters/" + wixCurrentFilter.filter_number + ".png";
                    string wiximgUrl = String.Empty;
                    string wiximgUrlLarge = String.Empty;
                    var wixrequest = (HttpWebRequest)WebRequest.Create(wiximgPath);
                    wixrequest.Method = "HEAD";
                    try
                    {
                        var response = (HttpWebResponse)wixrequest.GetResponse();
                        wiximgUrl = wiximgPath;
                        wiximgUrlLarge = @"http://wixeurope.com/Content/images/filters/" + wixCurrentFilter.filter_number + ".png";
                    }
                    catch
                    {
                        string RepImageName = "temp/example_filter_english.png";
                        wiximgUrl = String.Format(@"http://wixeurope.com/Content/images/{0}", RepImageName);
                        wiximgUrlLarge = wiximgUrl;
                    }

                    if (wixCurrentFilter != null) {
                        wixFilterObject.Id = wixCurrentFilter.filter_id;
                        wixFilterObject.Number = wixCurrentFilter.filter_number;
                        wixFilterObject.OutsideDiaTop = parseAndConvertInchesToMetric(wixCurrentFilter.filter_outside_dia_top);
                        wixFilterObject.OutsideDiaBottom = parseAndConvertInchesToMetric(wixCurrentFilter.filter_outside_dia_bottom);
                        wixFilterObject.InsideDiaTop = parseAndConvertInchesToMetric(wixCurrentFilter.filter_inside_dia_top);
                        wixFilterObject.Height = parseAndConvertInchesToMetric(wixCurrentFilter.filter_height);
                        wixFilterObject.ThreadSize = wixCurrentFilter.filter_thread_size;
                        wixFilterObject.FilterStyle = getFilterStyle(Convert.ToInt32(wixCurrentFilter.filter_style_id));
                        wixFilterObject.FilterType = getFilterType(Convert.ToInt32(wixCurrentFilter.filter_type_id));
                        wixFilterObject.FilterMedia = getMediaType(Convert.ToInt32(wixCurrentFilter.filter_media_id));
                        wixFilterObject.FilterService = getFilterService(Convert.ToInt32(wixCurrentFilter.filter_service_id));
                        wixFilterObject.PrincipleApplications = wixCurrentFilter.filter_principle_applications;
                        wixFilterObject.t_Filter = translationHelper.getTranslation("_filter", languageName);
                        wixFilterObject.t_Sizes = translationHelper.getTranslation("_hlpSizes", languageName);
                        wixFilterObject.t_OutsideDiaTop = translationHelper.getTranslation("_outerDiamaterTop", languageName);
                        wixFilterObject.t_OutsideDiaBottom = translationHelper.getTranslation("_outerDiamaterBottom", languageName);
                        wixFilterObject.t_InsideDiaTop = translationHelper.getTranslation("_innerDiameter", languageName);
                        wixFilterObject.t_Height = translationHelper.getTranslation("_height", languageName);
                        wixFilterObject.t_ThreadSize = translationHelper.getTranslation("_threadSize", languageName);
                        wixFilterObject.t_FilterStyle = translationHelper.getTranslation("_hlpFilterStyle", languageName);
                        wixFilterObject.t_FilterType = translationHelper.getTranslation("_hlpFilterType", languageName);
                        wixFilterObject.t_FilterMedia = translationHelper.getTranslation("_hlpFilterMedia", languageName);
                        wixFilterObject.t_FilterService = translationHelper.getTranslation("_hlpFilterService", languageName);
                        wixFilterObject.t_PrincipleApplications = translationHelper.getTranslation("_hlpApplication", languageName);
                        wixFilterObject.t_Zoom = translationHelper.getTranslation("_hlpZoom", languageName);
                        wixFilterObject.t_Yes = translationHelper.getTranslation("_hlpYes", languageName);
                        wixFilterObject.t_No = translationHelper.getTranslation("_hlpNo", languageName);
                        wixFilterObject.imageUrl = wiximgUrl;
                        wixFilterObject.largeImageUrl = wiximgUrlLarge;
                    }
                    return wixFilterObject.ToJSON();
            }
            return String.Empty;
        }

        public static decimal parseAndConvertInchesToMetric(decimal size) {
            return decimal.Round(size * (decimal)25.4, 2);
        }

        public static string ToJSON(this object obj) {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            return serializer.Serialize(obj);
        }

        public static string GetFilterDimG(decimal dimG, string dimGText) {
            if (!String.IsNullOrEmpty(dimGText))
            {
                return dimGText;
            }
            else {
                return Convert.ToString(dimG);
            }
        }

        public static string GetFiltronFilterWixNumber(String filterWixNumber, String filterWixNumberHd)
        {
            try
            {
                filterWixNumber = Regex.Replace(filterWixNumber, @"\s", "");
                filterWixNumberHd = Regex.Replace(filterWixNumberHd, @"\s", "");
                if ((!(String.IsNullOrEmpty(filterWixNumber))) && (!(String.IsNullOrEmpty(filterWixNumber))))
                {
                    if (filterWixNumber.ToUpper().StartsWith("W"))
                    {
                        return filterWixNumber;
                    }   //if
                    if (filterWixNumberHd.ToUpper().StartsWith("W"))
                    {
                        return filterWixNumberHd;
                    }   //if
                    return filterWixNumber;
                }   //if
                else if (!(String.IsNullOrEmpty(filterWixNumber)))
                {
                    return filterWixNumber;
                }   //if
                else if (!(String.IsNullOrEmpty(filterWixNumberHd)))
                {
                    return filterWixNumberHd;
                }   //if
                return String.Empty;
            }   //try
            catch (Exception ex)
            {
                Logger.MyLogger.Log(ex);
            }   //catch
            return String.Empty;
        }

        public static string getFilterStyle(int styleId)
        {
            IWixFilterStyleDAO filterStyleDAO = new WixFilterStyleDAO();
            if (styleId > 0)
            {
                return filterStyleDAO.FindByPK(Convert.ToInt32(styleId)).style_name;
            }
            return String.Empty;
        }

        public static string getFilterType(int typeId)
        {
            IWixFilterTypeDAO filterTypeDAO = new WixFilterTypeDAO();
            if (typeId > 0)
            {
                return filterTypeDAO.FindByPK(Convert.ToInt32(typeId)).type_name;
            }
            return String.Empty;
        }

        public static string getMediaType(int mediaId)
        {
            IWixFilterMediaDAO filterMediaDAO = new WixFilterMediaDAO();
            if (mediaId > 0)
            {
                return filterMediaDAO.FindByPK(Convert.ToInt32(mediaId)).media_name;
            }
            return String.Empty;
        }

        public static string getFilterService(int serviceId)
        {
            switch (serviceId)
            {
                case 3:
                    return "FF";
                case 4:
                    return "BP";
                case 5:
                    return "KT";
                case 6:
                    return "FB";
            }
            return String.Empty;
        }

    }

    public class CustomDoubleVarObject {
        public int Id { get; set; }
        public string Name { get; set; }
        public CustomDoubleVarObject() { }
        public CustomDoubleVarObject(int id, string name) {
            Id = id;
            Name = name;
        }
    }

    public class EngineObject {
        public int Id { get; set; }
        public string Name { get; set; }
        public string CubicCapacity { get; set; }
        public string Code { get; set; }
        public string HorsePower { get; set; }
        public EngineObject() { }
        public EngineObject(int id, string name) {
            Id = id;
            Name = name;
        } 
        public EngineObject(int id, string name, string cubic_capacity, string code, string horse_power) {
            Id = id;
            Name = name;
            CubicCapacity = cubic_capacity;
            Code = code;
            HorsePower = horse_power;
        }
    }

    public class FiltronFilterObject {
        public int Id { get; set; }
        public string Number { get; set; }
        public decimal DimA { get; set; }
        public decimal DimB { get; set; }
        public decimal DimC { get; set; }
        public decimal DimD { get; set; }
        public decimal DimE { get; set; }
        public decimal DimF { get; set; }
        public string DimG { get; set; }
        public decimal DimH { get; set; }
        public bool ByPassValve { get; set; }
        public bool AntiDrainValve { get; set; }
        public bool AntiSiphonValve { get; set; }
        public string PrincipleApplications { get; set; }
        public string t_Filter { get; set; }
        public string t_Sizes { get; set; }
        public string t_ByPassValve { get; set; }
        public string t_AntiDrainValve { get; set; }
        public string t_AntiSiphonValve { get; set; }
        public string t_PrincipleApplications { get; set; }
        public string t_Zoom { get; set; }
        public string t_Yes { get; set; }
        public string t_No { get; set; }
        public string imageUrl { get; set; }
        public string largeImageUrl { get; set; }

        public FiltronFilterObject() { }
        
    }

    public class WixFilterObject
    {
        public int Id { get; set; }
        public string Number { get; set; }
        public decimal OutsideDiaTop { get; set; }
        public decimal OutsideDiaBottom { get; set; }
        public decimal InsideDiaTop { get; set; }
        public decimal Height { get; set; }
        public string ThreadSize { get; set; }
        public string FilterStyle { get; set; }
        public string FilterType { get; set; }
        public string FilterMedia { get; set; }
        public string FilterService { get; set; }
        public string PrincipleApplications { get; set; }
        public string t_Filter { get; set; }
        public string t_Sizes { get; set; }
        public string t_OutsideDiaTop { get; set; }
        public string t_OutsideDiaBottom { get; set; }
        public string t_InsideDiaTop { get; set; }
        public string t_Height { get; set; }
        public string t_ThreadSize { get; set; }
        public string t_FilterStyle { get; set; }
        public string t_FilterType { get; set; }
        public string t_FilterMedia { get; set; }
        public string t_FilterService { get; set; }
        public string t_PrincipleApplications { get; set; }
        public string t_Zoom { get; set; }
        public string t_Yes { get; set; }
        public string t_No { get; set; }
        public string imageUrl { get; set; }
        public string largeImageUrl { get; set; }

        public WixFilterObject() { }
    }

}
